
import UIKit

class readtwareViewController: UIViewController
{

    var twareinfo:resourcejson? = nil
    var timer:Timer!
    func Alarm()
    {
        let alarm=UIAlertController(title: "提示", message: "收藏，关注功能尚未上线", preferredStyle: .alert)
        alarm.addAction(UIAlertAction(title: "好", style: .cancel, handler: nil))
        self.present(alarm, animated: true, completion: nil)
    }

    @IBAction func Tap(_ sender: UITapGestureRecognizer)
    {
      self.navigationController?.setNavigationBarHidden(false , animated: true)
        timer=Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.setbarhide), userInfo: nil, repeats: true)
    }
    func setbarhide()
    {
        self.navigationController?.setNavigationBarHidden(true , animated: true)
    }
    var scrollView:pdfScrollView!
    override func viewDidLoad()
    {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        self.navigationController?.setNavigationBarHidden(true, animated: true)
        pdfConfiguration()
        self.navigationController?.navigationBar.tintColor = UIColor.white
        self.navigationItem.rightBarButtonItem=UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(Alarm))
    }
    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func pdfConfiguration()
    {
        self.view.backgroundColor = UIColor(red: 248/255, green: 250/255, blue: 254/255, alpha: 1)
        self.automaticallyAdjustsScrollViewInsets = false
        
        let url = URL(string: (twareinfo?.resourcepath)!)
        
        let pdf = CGPDFDocument.init(url! as CFURL)
        
        scrollView = pdfScrollView(frame: view.frame)
        scrollView.backgroundColor = UIColor.lightGray
        scrollView.PDF = pdf!
        scrollView.initialize()
        //scrollView.pdfScrollviewDelegate = self
        view.addSubview(scrollView)
    }
    
    /*func back(){
     self.navigationController?.popViewController(animated: true)
     }*/
    
    func viewForZooming(in scrollView: UIScrollView) -> UIView?
    {
        for subView in scrollView.subviews
        {
            return subView
        }
        return nil
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
